home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / sendmail / ease-3.5 / doc / ease.paper < prev    next >
Encoding:
Text File  |  1991-10-15  |  32.2 KB  |  912 lines

  1. ...
  2. ... $Header: /tmp_mnt/home/kreskin/u0/barnett/Src/Ease/ease/doc/RCS/ease.paper,v 3.3 1991/09/09 16:36:05 barnett Exp $
  3. ... 
  4. ... $Log: ease.paper,v $
  5. ... Revision 3.3  1991/09/09  16:36:05  barnett
  6. ... minor bug fixes
  7. ...
  8. ... Revision 2.0  1990/01/30  12:50:44  jeff
  9. ... Baseline version, corresponding to netwide release 2.0.
  10. ...
  11. ... Revision 1.6  88/06/15  10:12:36  root
  12. ... Some editorial cleanup, added Acknowledgements section.
  13. ... 
  14. ... Revision 1.5  88/01/21  17:19:35  root
  15. ... Several editorial changes. ADR.
  16. ... 
  17. ... Revision 1.4  87/12/23  11:30:47  root
  18. ... Updated list of authors. Documented extended canon() capability.
  19. ... Integrated fluke changes in a little better. ADR.
  20. ... 
  21. ... Revision 1.3  87/11/04  11:33:45  root
  22. ... Documented new keyword "while" which is equivalent to "if". ADR.
  23. ... 
  24. ... Revision 1.2  87/08/13  17:08:05  root
  25. ... Changes from Jeff Stearns, fluke!jeff, for Sun. ADR.
  26. ... 
  27. ... Revision 1.1  87/08/13  17:05:00  root
  28. ... Initial revision
  29. ... 
  30. ...
  31. .LP
  32. .TL
  33. Ease: A Configuration Language
  34. for Sendmail
  35. .AU
  36. James S. Schoner
  37. .AI
  38. Purdue University Computing Center
  39. West Lafayette, Indiana  47907
  40. .AU
  41. Jeff P. Stearns
  42. .AI
  43. John Fluke Manufacturing Company
  44. Everett, Washington  98206
  45. .AU
  46. Arnold D. Robbins
  47. .AI
  48. Emory University Computing Center
  49. Atlanta, Georgia  30322
  50. .AU
  51. Bruce G. Barnett
  52. .AI
  53. General Electric Corporate Research and Development
  54. Schenectady, NY 12301
  55. .sp 2
  56. .I
  57. .ce
  58. ABSTRACT
  59. .R
  60. .PP
  61. The rapid expansion of computer networks and ensuing variation among mailing
  62. address formats have made address interpretation an increasingly
  63. complex task.  In the UNIX* 4.2BSD operating system, a program named 
  64. \fIsendmail\fR was introduced which provided a
  65. general internetwork mail routing facility.  This facility has significantly
  66. diminished the complexity of handling address interpretation.
  67. .PP
  68. \fISendmail\fR's address interpretation is based on a rewriting
  69. system composed of
  70. a number of rewriting rules (or productions) arranged as part of a 
  71. configuration file.  Unfortunately, the syntactical format of a
  72. configuration file for \fIsendmail\fR is both terse and rigid, making it
  73. rather difficult to modify.  The standard format certainly serves its 
  74. purpose, but, as 
  75. the need to change these configurations increases in frequency, a more 
  76. readable format (i.e., one that is similar to the format 
  77. of modern programming languages) is required to permit reasonably 
  78. quick modifications to the configuration.  As a solution to this problem, 
  79. \fBEase\fR 
  80. provides a level of abstraction which eliminates most of the current
  81. syntactic hindrances
  82. faced by programmers who must reconfigure \fIsendmail\fR's 
  83. address parsing scheme.  
  84. .PP
  85. As a high-level specification format, \fBEase\fR is proving to be an 
  86. excellent alternative to \fIsendmail\fR's cryptic 
  87. configuration file syntax.  The syntactic structures of \fBEase\fR 
  88. are patterned after modern language constructs, making the language
  89. easy to learn and easy to remember.  The format of the address rewriting
  90. rule is perhaps the most significant syntactical improvement.  It was 
  91. undoubtedly
  92. the most needed improvement.  Nevertheless, every element of a configuration 
  93. file is structurally enhanced through the use of \fBEase\fR. 
  94. .FS
  95. *  UNIX is a registered trademark of AT&T.
  96. .FE
  97. .sp 2
  98. .NH
  99. Introduction
  100. .PP
  101. The \fBEase\fR language is a high-level specification format for \fIsendmail\fR's
  102. configuration file.  The motivation for its development
  103. was to fulfill a goal of providing a readable and easily modifiable 
  104. \fIsendmail\fR configuration file format.  \fBEase\fR fulfills this goal by
  105. shielding the programmer from the cryptic configuration specification required
  106. by \fIsendmail\fR and providing a high-level language with which the programmer
  107. may specify all modifications to a configuration file.  The development 
  108. of Ease coincided with
  109. the development of an \fBEase\fR translator, \fIet\fR,
  110. which translates a configuration file written 
  111. in \fBEase\fR to an
  112. equivalent file of the standard format accepted by \fIsendmail\fR.
  113. .NH
  114. Ease in Profile
  115. .PP
  116. As will be seen in the next section, the syntax of \fBEase\fR is quite
  117. readable and easy to learn.  
  118. In order to acquire a relevant perspective
  119. on this issue,
  120. the reader is advised to examine a raw configuration file for \fIsendmail\fR (the 
  121. output
  122. of the \fBEase\fR translator, \fIet\fR, will do nicely).  The raw syntax, while
  123. quite fitting for quick translation, can prove to be a programmer's nightmare.  
  124. .PP
  125. It is recommended that you learn \fBEase\fP by converting your current
  126. configuration file into \fBEase\fP format by using the program
  127. \fIcfc\fP written by Arnold Robbins and modified by Bruce G. Barnett.
  128. .PP
  129. Undoubtedly, one of the more prominent features of \fBEase\fR is the ability 
  130. to attach
  131. names to address fields.  When address field names are well-chosen, a distinct,
  132. self-documenting quality becomes a visible part of the address rewriting 
  133. rules.  Ostensibly, address field names provide a new level of semantic 
  134. abstraction.  A brief comparison of the formats can be accomplished by examining
  135. the following equivalent representations of an address pattern:
  136. .DS
  137.     user_path@host_name            (\fBEase\fR format)
  138.     $+@$-                    (raw format)
  139. .DE
  140. In the above, \*Quser_path\*U represents a field of one or more address
  141. tokens, and \*Qhost_name\*U represents one address token exactly.  These
  142. token fields are represented by \*Q$+\*U and \*Q$-\*U in the raw format.  Clearly, 
  143. the \fBEase\fR format is preferable, not only for increased readability, but 
  144. structural comprehension as well.
  145. .PP
  146. Other features of \fBEase\fR include ruleset naming, long identifiers for 
  147. macros and classes, flow-of-control structures, and free formatting.  In
  148. addition, it supports C language preprocessor (cpp) commands, which can be used for file inclusion
  149. and conditionally defined code constructs.  The next section describes
  150. the \fBEase\fR language in complete detail.
  151. .NH
  152. Ease Syntax*
  153. .FS
  154. *  \fINo attempt is made to describe the complete semantic meaning 
  155. associated with all of the constructs of a sendmail configuration file.  Items 
  156. not covered in this document include the semantic distinction among rulesets, 
  157. the special uses of
  158. pre-defined macros, and the method of building configuration files.  To
  159. obtain this information, the reader is advised to refer to
  160. the Sendmail Installation and Operation Guide (SMM:7 in the 4.3 BSD
  161. UNIX System Manager's Manual),
  162. by Eric Allman.\fR
  163. .FE
  164. .PP
  165. At its highest level, \fBEase\fR can be viewed as a collection of 
  166. block-structures, where each block begins with a keyword and is followed by
  167. zero or more related definitions and/or declarations.  There are ten distinct 
  168. block types.  The following is 
  169. a list containing all ten block keywords and the block type it denotes.
  170. .TS
  171. center;
  172. l l .
  173. \fIbind\fR    -ruleset identifier bindings
  174. \fImacro\fR    -macro definitions
  175. \fIclass\fR    -class definitions
  176. \fIoptions\fR    -\fIsendmail\fR option definitions
  177. \fIprecedence\fR    -precedence definitions
  178. \fItrusted\fR    -trusted users
  179. \fIheader\fR    -mail header definitions
  180. \fImailer\fR    -mailer definitions
  181. \fIfield\fR    -address field definitions
  182. \fIruleset\fR    -address rewriting rules
  183. .TE
  184. .sp 1
  185. In general,
  186. .TS
  187. center ;
  188. l .
  189.  
  190. * Letters are distinguished by case,
  191.  
  192. T{
  193. * An \fBEase\fR identifier is defined to be a letter, followed by zero or 
  194. more letters, digits, underscores (_), or dashes (-),
  195. T}
  196.  
  197. T{
  198. * A literal newline or double quotation (") character may be included in 
  199. any quoted string by preceding the character with a backslash (\\\\\), and
  200. T}
  201.  
  202. T{
  203. * \fBEase\fR source is preprocessed by the C language preprocessor (cpp)
  204. if the program is executed with an option understood by cpp.
  205. Thus source comments (i.e., text enclosed by \*Q/*\*U and \*Q*/\*U) may appear 
  206. anywhere as part of \fBEase\fR whitespace.
  207. T}
  208. .TE
  209. .PP
  210. For notational convenience, this document specifies all reserved
  211. words of the \fBEase\fR language in italics.  In addition, quantities
  212. enclosed in angle brackets (<..>) represent arbitrary 
  213. identifiers, strings, or numbers.  
  214. .NH 2
  215. Ruleset Identifier Bindings
  216. .PP
  217. A ruleset (a set of rewriting rules) is identified solely by an integer 
  218. in \fIsendmail\fR's
  219. configuration file.  \fBEase\fR, however, allows each ruleset to be named with
  220. a meaningful identifier.  Since a special numeric association for each 
  221. ruleset is required by the address parsing scheme of \fIsendmail\fR, a \fIbind\fR
  222. block must be present in any \fBEase\fR file which defines one or more 
  223. rulesets.  A
  224. \fIbind\fR block consists of the keyword \fIbind\fR, followed by zero or more
  225. statements of the form:
  226. .TS
  227. center box;
  228. l .
  229. <ruleset-id> = \fIruleset\fR <ruleset-number> ;
  230. .TE
  231. The following example, 
  232. .sp 1
  233. \fIbind\fR
  234. .PP
  235. FINAL_RW = \fIruleset\fR 4;
  236. .sp 1
  237. specifies that FINAL_RW, the final rewriting ruleset, is \fIsendmail\fR's ruleset 
  238. number 4.
  239. .NH 2
  240. Macro Definitions
  241. .PP
  242. A macro is an identifier which, when referenced in the text of a program,
  243. is replaced by its value, a string of zero or more characters.  The value
  244. of a macro may include references to other macros, but not itself!  \fISendmail\fR
  245. allows a maximum of 26 user-declared macros in its configuration file.  In 
  246. addition, there are a number of pre-declared macros which have special meaning
  247. to \fIsendmail\fR (see Appendix A).  \fBEase\fR macros are defined in 
  248. \fImacro\fR blocks.  \fBEase\fR allows any macro to be declared 
  249. (which is equivalent to simply referencing it) before it is defined.  A macro
  250. identifier is replaced by its value when it is preceded by the character
  251. \*Q$\*U.  In addition, a macro reference inside a quoted string must always 
  252. include braces ({}) around the macro identifier (for delimiting purposes).  
  253. .PP
  254. A \fImacro\fR block consists of the keyword \fImacro\fR, followed by zero
  255. or more statements taking either of the following forms:
  256. .TS
  257. center box;
  258. l .
  259. <macro-identifier> = "<macro-value>" ;
  260. <macro-identifier> = \fBconditional-expression\fR ;
  261. .TE
  262. The \fBconditional-expression\fR format will be discussed 
  263. later.  
  264. .sp 1
  265. The following example,
  266. .sp 1
  267. \fImacro\fR
  268. .PP
  269. first_name = "James";
  270. .PP
  271. last_name = "Schoner";
  272. .PP
  273. whole_name = "${first_name} ${last_name}";
  274. .sp 1
  275. defines the macros first_name, last_name, and whole_name, where whole_name
  276. is the string, "James Schoner".
  277. .NH 2
  278. Class definitions
  279. .PP
  280. A class is denoted by an identifier representing a logical grouping of zero 
  281. or more names.  Classes are used to represent the range of values a token
  282. may assume in the pattern matching of an address.  Further discussion on the
  283. use of classes will be deferred until address fields are described.
  284. .PP
  285. One identifier may be used to distinctly represent both a macro
  286. and class (i.e., the set of macro identifiers and the set of class identifiers
  287. may form a non-empty intersection).  A name, or class element, may 
  288. be an identifier or any quoted word.
  289. .PP
  290. A \fIclass\fR block consists of the keyword \fIclass\fR, followed by zero
  291. or more statements taking any of the following forms:
  292. .TS
  293. center box;
  294. l .
  295. <class-identifier> = { <name1>, <name2>, <name3>, ... } ;
  296. <class-identifier> = \fIreadclass\fR ( "<file-name>" ) ;
  297. <class-identifier> = \fIreadclass\fR ( "<file-name>", "<read-format>" ) ;
  298. .TE
  299. The second and third forms cause \fIsendmail\fR to read the names of the class 
  300. from the named
  301. file.  The third form contains a read format, which should be a \fIscanf\fR(3)
  302. pattern yielding a single string.
  303. .sp 1
  304. The following example,
  305. .sp 1
  306. \fIclass\fR
  307. .PP
  308. campus_hosts = { statistics, engineering, chemistry, physics, physics-2 } ;
  309. .PP
  310. versions     = { "1.0", "1.1", "4.0", "4.2", latest-and-greatest } ;
  311. .PP
  312. phone_hosts  = \fIreadclass\fR ( "/tmp/phonenet.list" ) ;
  313. .sp 1
  314. defines the classes campus_hosts, versions, and phone_hosts.
  315. .NH 2
  316. Sendmail option definitions
  317. .PP
  318. A number of options to the \fIsendmail\fR program may be specified in 
  319. an \fIoptions\fR
  320. block.  For a description of the various \fIsendmail\fR options and their 
  321. values, see Appendix B.  
  322. .PP
  323. An
  324. \fIoptions\fR block consists of the keyword \fIoptions\fR, followed by zero
  325. or more statements taking any of the following forms:
  326. .TS
  327. center box;
  328. l l .
  329. <option-identifier>    = "<option-value>" ;
  330. \fIo_delivery\fR    = \fBspecial-value\fR ;
  331. \fIo_handling\fR    = \fBspecial-value\fR ;
  332. .TE
  333. All but two options (\fIo_delivery\fR and \fIo_handling\fR) use the first 
  334. form.  To specify an option without a value, simply assign to it the null 
  335. string ("").  The \fBspecial-value\fR field of the second and third form
  336. refers to special values (non-quoted) which are specified in Appendix B.
  337. .sp 1
  338. The following example,
  339. .sp 1
  340. \fIoptions\fR
  341. .PP
  342. \fIo_alias\fR = "/usr/lib/aliases" ;
  343. .PP
  344. \fIo_tmode\fR = "0600" ;
  345. .PP
  346. \fIo_delivery\fR = \fId_background\fR ;
  347. .sp 1
  348. sets the options \fIo_alias\fR, \fIo_tmode\fR, and \fIo_delivery\fR.
  349. .NH 2
  350. Precedence definitions
  351. .PP
  352. Message headers may contain a \*QPrecedence:\*U field describing the precedence
  353. of the message class.  Identifiers which may appear in the precedence field of
  354. a message are given precedence values in a configuration file \fIprecedence\fR 
  355. definition.  This association will be illustrated below in an example.
  356. .PP
  357. A \fIprecedence\fR block consists of the keyword \fIprecedence\fR, followed 
  358. by zero or more statements of the form:
  359. .KS
  360. .TS
  361. center box;
  362. l .
  363. <precedence-identifier> = <precedence-integer> ;
  364. .TE
  365. .KE
  366. The following example,
  367. .sp 1
  368. \fIprecedence\fR
  369. .PP
  370. special-delivery = 100;
  371. .PP
  372. junk = -100;
  373. .sp 1
  374. defines the precedence level for the names \*Qspecial-delivery\*U and 
  375. \*Qjunk\*U.  Thus, whenever the name \*Qjunk\*U appears in 
  376. a \*QPrecedence:\*U field, the corresponding message class will be set to -100.
  377. .NH 2
  378. Trusted users
  379. .PP
  380. \fISendmail\fR's \fB\-f\fR flag allows trusted users to override the sender's
  381. machine address.  Trusted users are listed in \fItrusted\fR blocks.  A 
  382. \fItrusted\fR block consists of the keyword \fItrusted\fR, followed 
  383. by zero or more sets of users taking the form:
  384. .TS
  385. center box;
  386. l .
  387. { <user1>, <user2>, <user3>, ... } ;
  388. .TE
  389. The following example,
  390. .sp 1
  391. \fItrusted\fR
  392. .PP
  393. { root, uucp, network } ;
  394. .PP
  395. { acu, kcs, jss } ;
  396. .sp 1
  397. specifies that the users root, uucp, network, acu, kcs, and jss can be trusted 
  398. to use the \fIsendmail\fR flag, \fB\-f\fR.
  399. .NH 2
  400. Mail header definitions
  401. .PP
  402. The format of the message headers inserted by \fIsendmail\fR is defined in one
  403. or more \fIheader\fR blocks in the configuration file.  A \fIheader\fR block
  404. consists of the keyword \fIheader\fR, followed by zero or more statements
  405. taking any of the following forms:
  406. .TS
  407. center box;
  408. l
  409. l
  410. l
  411. l
  412. l
  413. l
  414. l
  415. l
  416. l
  417. l .
  418. \fIfor\fR ( <mailer-flag1>, <mailer-flag2>, ... )
  419.        \fIdefine\fR ( "<header-title>" , \fBheader-value\fR ) ;
  420.  
  421. \fIfor\fR ( <mailer-flag1>, <mailer-flag2>, ... ) {
  422.        \fIdefine\fR ( "<header-title>" , \fBheader-value\fR ) ;
  423.        \fIdefine\fR ( "<header-title>" , \fBheader-value\fR ) ;
  424.        .
  425.        .
  426. } ;
  427.  
  428. \fIdefine\fR ( "<header-title>" , \fBheader-value\fR ) ;
  429. .TE
  430. The first form is used to define one header for one or more mailer
  431. flags.  The second form differs from the first in that more than one
  432. header may be defined for a given set of flags.  The third form is used to 
  433. define a header,
  434. regardless of mailer flags.  Refer to Appendix C for a list of \fBEase\fR 
  435. identifiers representing mailer flags.  The header title is a simple
  436. string of characters (no macro references), whereas the \fBheader-value\fR
  437. is a series of one or more strings and
  438. \fBconditional-expressions\fP (discussed later).
  439. Concatenation is implicit (as in \fIawk\fP).
  440. .sp 1
  441. The following example,
  442. .DS
  443. \fIheader\fR
  444.  
  445.     \fIdefine\fR ( "Subject:", "") ;
  446.  
  447.     \fIfor\fR ( \fIf_return\fR )
  448.         \fIdefine\fR ( "Return-Path:", "<${\fIm_sreladdr\fR}>" ) ;
  449.  
  450.     \fIfor\fR ( \fIf_date\fR ) {
  451.         \fIdefine\fR ( "Resent-Date:", "${\fIm_odate\fR}" ) ;
  452.         \fIdefine\fR ( "Date:", "${\fIm_odate\fR}" );
  453.     } ;
  454. .DE
  455. defines a \*QSubject\*U field for all mailers, regardless of their flags, a
  456. \*QReturn-Path\*U field for mailers whose definition specifies
  457. the flag, \fIf_return\fR, and the headers, \*QResent-Date\*U and \*QDate\*U,
  458. for mailers whose definition specifies the flag, \fIf_date\fR.
  459. .NH 2
  460. Mailer Definitions
  461. .PP
  462. \fISendmail\fR's definition of a mailer (or an interface to one) occurs in a
  463. \fImailer\fR block.  A \fImailer\fR block consists of the keyword \fImailer\fR,
  464. followed by zero or more statements of the form:
  465. .TS
  466. center box;
  467. l .
  468. <mailer-identifier> { \fBmailer-spec\fR } ;
  469. .TE
  470. The field, \fBmailer-spec\fR, is a list of zero or more of the
  471. following attribute assignments (where successive assignment statements are
  472. separated by commas):
  473. .TS
  474. center ;
  475. l l 
  476. l l
  477. l l
  478. l l
  479. l l
  480. l l
  481. l l .
  482. \fIPath\fR    = \fBstring-attribute\fR
  483. \fIArgv\fR    = \fBstring-attribute\fR
  484. \fIEol\fR    = \fBstring-attribute\fR
  485. \fIMaxsize\fR    = \fBstring-attribute\fR
  486. \fIFlags\fR    = { <mailer-flag1>, <mailer-flag2>, ... } 
  487. \fISender\fR    = <sender-ruleset-id>
  488. \fIRecipient\fR    = <recipient-ruleset-id>
  489. .TE
  490. The \fBstring-attribute\fR value can take the form of a quoted string
  491. (possibly containing macro references) or a \fBconditional-expression\fR 
  492. (discussed later).
  493. .sp 1
  494. The following example,
  495. .sp 1
  496. \fImailer\fR
  497. .DS
  498.     local {
  499.         \fIPath\fR        = "/bin/mail",
  500.         \fIFlags\fR        = { \fIf_from\fR, \fIf_locm\fR },
  501.         \fISender\fR    = Sender_RW,
  502.         \fIRecipient\fR    = Recip_RW,
  503.         \fIArgv\fR        = "mail -d ${\fIm_ruser\fR}",
  504.         \fIMaxsize\fR    = "200000"
  505.     } ;
  506. .DE
  507. defines a mailer named \*Qlocal\*U.
  508. .NH 2
  509. Address field definitions
  510. .PP
  511. \fISendmail\fR's address parsing scheme treats an address as a group of tokens
  512. (an address token is precisely defined in the Arpanet protocol RFC822).  In
  513. general, \fIsendmail\fR divides an address into tokens based on a list of
  514. characters assigned as a string to the special macro \fIm_addrops\fR.  These
  515. characters will individually be considered as tokens and will separate tokens
  516. when parsing is performed. 
  517. .PP
  518. For
  519. the \fBEase\fR language, there is a distinct set of address tokens (defined
  520. below) which are used in combination to represent generic forms of 
  521. addresses.  In 
  522. addition to literal address tokens, the pattern to be matched in a rewriting 
  523. rule (often referred to as the LHS) may
  524. include field identifiers which match one of five possibilities:
  525. .DS
  526.     - zero or more tokens
  527.     - one or more tokens
  528.     - one token exactly
  529.     - one token which is an element of an arbitrary class \fBX\fR
  530.     - one token which is not an element of an arbitrary class \fBX\fR
  531. .DE
  532. A particular field type may be assigned to one or more identifiers.  Each
  533. field identifier is associated with (or defined to be) a field type in
  534. a \fIfield\fR declarations block.  A \fIfield\fR declarations block consists
  535. of the keyword \fIfield\fR, followed by zero or more field definitions of
  536. the form:
  537. .TS
  538. center box;
  539. l .
  540. \fBfield-id-list\fR : \fBfield-type\fR ;
  541. .TE
  542. A \fBfield-id-list\fR is a list of one or more identifiers, each separated by
  543. a comma.  A \fBfield-type\fR, on the other hand, is a representation of 
  544. one of the five fields 
  545. described above.  The syntax for each of the five forms follows:
  546. .DS
  547.     \fImatch\fR ( 0* )
  548.     \fImatch\fR ( 1* )
  549.     \fImatch\fR ( 1 )
  550.     \fImatch\fR ( 1 ) \fIin\fR <class-X>
  551.     \fImatch\fR ( 0 ) \fIin\fR <class-X>
  552. .DE
  553. The star in the first two forms means: "or more".  Thus, the first
  554. form would read: "match zero or more tokens".  The fourth form describes
  555. a field where one token is matched from an arbitrary class (class-X), whereas
  556. the fifth form describes a field where one token is matched if it is not of the
  557. given class (class-X).
  558. .sp 1
  559. In addition, the Sun release 3.0 version of \fIsendmail\fR supports several
  560. new pattern matching operations represented by the following forms:
  561. .DS
  562.     \fImatch\fR ( 0 ) \fImap\fR <macro-identifier-X>
  563.     \fImatch\fR ( 1 ) \fImap\fR <macro-identifier-X>
  564.     \fImatch host\fR
  565. .DE
  566. The macro \*Qmacro-identifier-X\*U should be assigned the name of the
  567. relevant YP map.
  568. .sp 1
  569. The following example,
  570. .sp 1
  571. .DS
  572. \fIfield\fR
  573.     anypath        : \fImatch\fR ( 0* );
  574.     recipient_host    : \fImatch\fR ( 1 );
  575.     local_site        : \fImatch\fR ( 1 ) \fIin m_sitename\fR;
  576.     remote_site        : \fImatch\fR ( 0 ) \fIin m_sitename\fR;
  577. .DE
  578. defines the fields anypath, recipient_host, local_site, and remote_site.
  579. .NH 2
  580. Address rewriting rules
  581. .PP
  582. Address rewriting rules are grouped according to the function they perform.  For
  583. example, it is desirable to form a distinct group for those rewriting rules 
  584. which perform transformations on recipient addresses.
  585. .PP
  586. Sets of rewriting rules are defined in \fIruleset\fR blocks.  A \fIruleset\fR
  587. block consists of the keyword \fIruleset\fR, followed by zero or more
  588. ruleset definitions of the form:
  589. .TS
  590. center box;
  591. l .
  592. <ruleset-id> { <rewriting-rule1> <rewriting-rule2> ... }
  593. .TE
  594. The ruleset identifier, ruleset-id, must be defined in a \fIbind\fR block, as
  595. described earlier.  The rewriting rules have the form:
  596. .DS
  597.     \fIif\fR ( <match-pattern> )
  598.         <match-action> ( <rewriting-pattern> ) ;
  599. .DE
  600. where match-pattern, rewriting-pattern, and match-action are described below.
  601. An alternative form is available:
  602. .DS
  603.     \fIwhile\fR ( <match-pattern> )
  604.         <match-action> ( <rewriting-pattern> ) ;
  605. .DE
  606. which is somewhat more useful when the \*Qmatch-action\*U is \fIretry\fP
  607. (see below).
  608. .NH 3
  609. Match-patterns
  610. .PP
  611. A match-pattern is a sequence of Ease address elements representing an
  612. address format.  If the address being rewritten matches the pattern
  613. \*Qmatch-pattern\*U,
  614. then the address is reformatted using the pattern \*Qrewriting-pattern\*U, and 
  615. the corresponding
  616. action (\*Qmatch-action\*U) is performed.  The five distinct Ease address
  617. elements which may constitute a match-pattern are as follows:
  618. .TS
  619. center ;
  620. l .
  621. 1. Field Identifiers (refer to previous section)
  622. T{
  623. 2. Non-alphanumeric characters (the exception is the case for literal 
  624. double quotes, which must be preceded by a backslash (\\\\\)
  625. T}
  626. 3. Macro references
  627. 4. Quoted strings ("...")
  628. 5. \fBConditional-expressions\fR (discussed later)
  629. .TE
  630. Below are two sample match-patterns, each describing the same address format:
  631. .DS
  632.     user-id @ hostname . $arpa_suffix
  633.     user-id @ hostname ".ARPA"
  634. .DE
  635. where user-id and hostname are field identifiers, and arpa_suffix is a 
  636. user-defined macro with the value \*QARPA\*U.
  637. .NH 3
  638. Rewriting-patterns
  639. .PP
  640. A rewriting-pattern specifies the form in which to rewrite a matched 
  641. address.  The seven distinct elements which may be used to form 
  642. a rewriting-pattern are as follows:
  643. .TS
  644. center ;
  645. l .
  646.  
  647. T{
  648. 1. Non-alphanumeric characters (the exception is the case for literal
  649. double quotes, left parentheses, or right parentheses, each of which 
  650. must be preceded by a backslash (\\\\\). 
  651. T}
  652.  
  653. T{
  654. 2. A call to another ruleset.  This is used to perform rewrites
  655. on a suffix of the rewriting-pattern.  The proper use of this
  656. feature will be demonstrated by example below. 
  657. T}
  658.  
  659. 3. Quoted strings ("...").
  660.  
  661. 4. \fBConditional-expressions\fR (discussed later).
  662.  
  663. 5. A macro reference.
  664.  
  665. T{
  666. 6. A positional reference in the matched address.  A positional 
  667. reference takes the form: $<integer-position>.  For example, 
  668. $3 references the value of the third \fBEase\fR address 
  669. element in the matched address.
  670. T}
  671.  
  672. T{
  673. 7. Canonicalized host names of the form \fIcanon\fR (<id-token-list>),
  674. where \*Qid-token-list\*U is a list of one or more \*Qid-tokens.\*U
  675. An \*Qid-token\*U is a regular identifier, a quoted identifier (with
  676. double quotes), a macro reference yielding an identifier,
  677. a numeric internet specification (see below),
  678. a literal character (such as a \*Q.\*U or a \*Q[\*U), or a 
  679. positional reference in the matched address.  The canonicalization of 
  680. a host name is simply a mapping to its canonical (or official) form.
  681. T}
  682.  
  683. .TE
  684. Below are two sample rewriting-patterns:
  685. .DS
  686.     $1 % $2 < @ $3 ".ARPA" >
  687.     OLDSTYLE_RW ( $1 )
  688. .DE
  689. The first form specifies an address such as a%b<@c.ARPA>, where a, b, and c
  690. represent matched identifiers or paths.  The second form specifies a call to
  691. the ruleset \*QOLDSTYLE_RW\*U, for old-style rewriting on the parameter 
  692. $1, which probably references the entire matched address.  This will become 
  693. clear in later examples.
  694. .NH 3
  695. Match-actions
  696. .PP
  697. When a ruleset is called, the address to be rewritten is compared (or matched)
  698. sequentially against the match-address of each rewriting rule.  When a
  699. match-address describes the address \fIsendmail\fR is attempting to rewrite, the
  700. address is rewritten (or reformatted) using the rule's 
  701. rewriting-pattern.  Following this rewrite, the corresponding match-action
  702. is performed.  There are four match-actions:
  703. .TS
  704. center ;
  705. l l .
  706. \fIretry\fR    T{
  707. -a standard action which causes the rewritten address
  708. to be again compared to the match-address of the current rule. 
  709. T}
  710.  
  711. \fInext\fR    T{
  712. -an action which causes the rewritten address to be
  713. compared to the match-address of the next rewriting rule of the current 
  714. ruleset.  If the end of the list is reached, the ruleset returns the 
  715. rewritten address.
  716. T}
  717.  
  718. \fIreturn\fR    T{
  719. -an action which causes an immediate return of the 
  720. ruleset with the current rewritten address.
  721. T}
  722.  
  723. \fIresolve\fR    T{
  724. -an action which specifies that the address has been
  725. completely resolved (i.e., no further rewriting is necessary).  The 
  726. \fIresolve\fR action is described in more detail below. 
  727. T}
  728. .TE
  729. .PP
  730. The match-action, \fIresolve\fR, is special in that it terminates
  731. the address rewriting altogether.  The semantic structure of \fIsendmail\fR's
  732. rewriting scheme requires that a \fIresolve\fR action appear only in the 
  733. ruleset whose numerical binding is to the number zero.  The \fIresolve\fR action
  734. must specify three parameters: \fImailer\fR, \fIhost\fR, and \fIuser\fR.  If
  735. the \fImailer\fR is local, the \fIhost\fR parameter may be omitted.  The
  736. \fImailer\fR argument must be specified as a single word, macro, or positional
  737. reference in the matched address.  The \fIhost\fR argument may be specified as 
  738. a single word or as an expression which expands to a single word (e.g.,
  739. \fIhost\fR ($1 ".ARPA")).  In addition, the \fIhost\fR argument may be a
  740. canonicalization (as described above) or a numeric internet specification.  The
  741. keyword \fIhostnum\fR is used for numeric internet specifications, as in 
  742. \fIhostnum\fR ("128.61.1.1") or \fIhostnum\fR ( $2 ).  The \fIuser\fR 
  743. specification is a rewriting-pattern, as described above.  
  744. .PP
  745. In general, the format of a \fIresolve\fR action will be as follows:
  746. .DS
  747.     \fIresolve\fR (    \fImailer\fR ( <mailer-name> ),
  748.             \fIhost\fR   ( <host-name> ),
  749.             \fIuser\fR   ( <user-address>)   );
  750. .DE
  751. Examples of the match-action statement are shown below:
  752. .DS
  753. \fIfield\fR
  754.     anypath    : \fImatch\fR (0*);
  755.     usr, path    : \fImatch\fR (1*);
  756.     hostname    : \fImatch\fR (1);
  757.     phone_host    : \fImatch\fR (1) \fIin\fR phonehosts;
  758. .DE
  759. .DS
  760. \fIruleset\fR
  761.  
  762.     EXAMPLE_RW {
  763.     
  764.         \fIif\fR ( anypath < path > anypath )   /* basic RFC821/822 parse */
  765.             \fIretry\fR ( $2 );
  766.         \fIif\fR ( usr " at " path )        /* \*Qat\*U -> \*Q@\*U */
  767.             \fInext\fR ( $1 @ $2 );
  768.         \fIif\fR ( @path: usr )
  769.             \fIreturn\fR ( LOCAL_RW ( < @$1 > : $2 ) );
  770.         \fIif\fR ( anypath < @phone_host".ARPA" > anypath )
  771.             \fIresolve\fR (    \fImailer\fR ( tcp ),
  772.                     \fIhost\fR ( relay.cs.net ),
  773.                     \fIuser\fR ( $1 % $2 < @"relay.cs.net" > $3 ) );
  774.     }
  775. .DE
  776. .PP
  777. The example above defines the ruleset \*QEXAMPLE_RW\*U, which contains four
  778. rewriting rules.  The first rewriting rule discards all tokens of an address
  779. which lie on either side of a pair of angle brackets (<>), thereby 
  780. rewriting the address as
  781. the sequence of tokens contained within the angle brackets ($2).  Following the
  782. address rewrite, the rule is applied again (\fIretry\fR).  When the first rule
  783. fails to match the address being rewritten, the second rule is applied.  
  784. .PP
  785. The second 
  786. rule simply replaces the word \*Qat\*U by the symbol \*Q@\*U.  The \*Q\fInext\fR\*U
  787. action specifies that if a match is made, a rewrite is performed and 
  788. matching continues at the next (or following) rule.  
  789. .PP
  790. The third rule illustrates
  791. the use of the \*Q\fIreturn\fR\*U action, which is executed if the 
  792. pattern \*Q@path: usr\*U
  793. describes the current format of the address being rewritten.  In this example,
  794. the \fIreturn\fR action returns the result of a call to ruleset \*QLOCAL_RW\*U,
  795. which rewrites the address \*Q<@$1>:$2\*U, where $1 and $2 are substituted
  796. with the token(s) matched respectively by \*Qpath\*U and \*Qusr\*U.
  797. .PP
  798. The fourth (and final) rule signals a resolution (and termination) of the
  799. rewriting process if the given pattern is matched.  The resolution specifies
  800. that the mailer \*Qtcp\*U will be used to deliver the message to the host
  801. \*Qrelay.cs.net\*U.
  802. The \fIuser\fR parameter specifies the final form of the address
  803. which \fIsendmail\fR has just resolved.
  804. .sp 2
  805. .PP
  806. The \fBEase\fR construct which remains to be examined is the 
  807. \fBconditional-expression\fR.  The \fBconditional-expression\fR provides a 
  808. method for
  809. constructing strings based on the condition that some test macro is (or is not)
  810. set.  The general form begins with the concatenation of a string and a
  811. \fBstring-conditional\fR:
  812. .DS
  813.     \fIconcat\fR ( <quoted-string>, \fBstring-conditional\fR )
  814.     \fIconcat\fR ( \fBstring-conditional\fR, <quoted-string> )
  815. .DE
  816. A \fBstring-conditional\fR assumes either of the following forms:
  817. .DS
  818.     \fIifset\fR ( <macro-name>, <ifset-string> )
  819.     \fIifset\fR ( <macro-name>, <ifset-string>, <notset-string> )
  820. .DE
  821. A \fBstring-conditional\fR of the first form evaluates to \*Qifset-string\*U 
  822. if the macro \*Qmacro-name\*U has been assigned a value; otherwise it
  823. evaluates to the null string.  The second form behaves similarly, except
  824. that the \fBstring-conditional\fR evaluates to \*Qnotset-string\*U, instead
  825. of the null string, if the macro \*Qmacro-name\*U has no value.
  826. .sp 1
  827. The following \fBconditional-expression\fR,
  828. .DS
  829.     \fIconcat\fR ( "New ", \fIifset\fR ( city, "York", "Jersey" ) )
  830. .DE
  831. evaluates to the string "New York", if the macro \*Qcity\*U is set.  Otherwise,
  832. the \fBconditional-expression\fR evaluates to the string "New Jersey".
  833. .NH 2
  834. Latest Changes
  835. The first two releases of \fBEase\fP provided a good starting point
  836. for managing \fIsendmail\fP  files. However, the translation wasn't
  837. perfect. Some editing needed to be done before \fBEase\fB could be
  838. used.
  839. Bruce G. Barnett made modifications to Arnold Robbin's \fBEase\fP to
  840. sendmail convertor \fIcfc\fP and tested these changes to verify a
  841. \fIsendmail\fP configuration fle could be translated into \fBEase\fP
  842. and back with no errors: at least for the more common versions of
  843. \fIsendmail\fP.
  844. In case this translation is not perfect, \fBEase\fP version 3 supports
  845. the \fIasm("...")\fP command, which passes the contents of the string
  846. directly to the \fIsendmail.cf\fP file.
  847. Also - support for SunOS and Ultrix sendmail were added.
  848. New options and flags were added, and well as the \fIypmap\fP (SunOS),
  849. \fIypalias\fP and \fIyppasswd\fP (Ultrix) functions.
  850. .NH
  851. Ease Translation
  852. .PP
  853. It is important to note that \fBEase\fR is translated by a stand-alone
  854. translator to the raw configuration file format.  No modifications were
  855. made to the \fIsendmail\fR program itself.  As a result, syntactical verification
  856. of a configuration file can be performed without invoking \fIsendmail\fR.
  857. .PP
  858. The \fBEase\fR language is translated by invoking 
  859. the \fBEase\fR translator (\fIet\fR). If the command line options include a flag understood by the C language preprocessor (cpp), \fIet\fP automatically 
  860. pipes input through \fIcpp\fP.
  861. The \fBEase\fR
  862. translator may be invoked on the command line in one of four ways:
  863. .TS
  864. center box ;
  865. l l .
  866. \fIet\fR <options>  <input-file>  <output-file>    [read from a file, write to a file]
  867. \fIet\fR  <options> <input-file>    [read from a file, write to standard output]
  868. \fIet\fR  <options> -  <output-file>    [read from standard input, write to a file]
  869. \fIet\fR <options>    [read from standard input, write to standard output]
  870. .TE
  871. .NH
  872. Conclusion
  873. .PP
  874. \fBEase\fR is [ed - this information is old] currently in use at the
  875. Purdue University Computing Center.  Source code for the \fBEase\fR
  876. translator (\fIet\fR) may be obtained on request by writing to:
  877. .DS
  878. U.S. Mail:
  879.         James S. Schoner
  880.         c/o Kevin S. Braunsdorf
  881.         Purdue University Computing Center
  882.         Purdue University
  883.         West Lafayette, Indiana  47907
  884.  
  885. Electronic Mail:
  886.         ksb@j.cc.purdue.edu
  887. .DE
  888. .PP
  889. Much of the success of this project is attributable to the constant support 
  890. and insight offered by Mark Shoemaker.  To him, I owe a debt of gratitude.  In 
  891. addition, I would like to thank Kevin Smallwood, Paul Albitz, and Rich Kulawiec
  892. for their many notable suggestions and valuable insight.
  893. .NH
  894. Acknowledgements
  895. .PP
  896. Arnold Robbins would like to acknowledge contributions from
  897. Stephen Schaefer of Bowling Green State University,
  898. Jeff Stearns of John Fluke Manufacturing Company,
  899. Raymond A. Schnitzler of Bellcore,
  900. Andrew Partan of the Corporation for Open Systems,
  901. and
  902. Bruce G. Barnett, of General Electric.
  903. The good intentions of Rich Salz, of Bolt Beranak, and Newman,
  904. are also acknowledged.
  905. .PP
  906. The most up to date version of \fBEase\fR should be gotten from the
  907. nearest USENET \fBcomp.sources.unix\fR archive site.
  908. # Local variables:
  909. # mode: nroff
  910. # end:
  911.